package com.zjdiepu.www.rest.api.system;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.core.ApiResponse;
import com.zjdiepu.www.base.enums.status.MortgageStatus;
import com.zjdiepu.www.base.enums.type.CreditPeopleType;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.common.consts.SystemConsts;
import com.zjdiepu.www.common.util.CollectionInitUtil;
import com.zjdiepu.www.commpent.RedisObjectClient;
import com.zjdiepu.www.ibiz.dz.IDzGpsService;
import com.zjdiepu.www.ibiz.dz.IDzLoanExitService;
import com.zjdiepu.www.ibiz.dz.IDzLoanMiddleAuditService;
import com.zjdiepu.www.ibiz.dz.IDzLoanMiddleBankService;
import com.zjdiepu.www.ibiz.dz.IDzMortgageService;
import com.zjdiepu.www.ibiz.dz.IDzMortgageSubService;
import com.zjdiepu.www.ibiz.dz.IDzRegistrationService;
import com.zjdiepu.www.ibiz.third.IJuheCityService;
import com.zjdiepu.www.ibiz.third.IJuheProvinceService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessBuyerService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessCarAreaPriceService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessCarService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessLoanService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessService;
import com.zjdiepu.www.ibiz.zx.IZxCreditQueryService;
import com.zjdiepu.www.ibiz.zx.IZxQueryCreditApplySubService;
import com.zjdiepu.www.model.base.dto.SimpleDataDictionary;
import com.zjdiepu.www.model.dz.dto.DzGps;
import com.zjdiepu.www.model.dz.dto.DzLoanExit;
import com.zjdiepu.www.model.dz.dto.DzLoanMiddleAudit;
import com.zjdiepu.www.model.dz.dto.DzLoanMiddleBank;
import com.zjdiepu.www.model.dz.dto.DzMortgage;
import com.zjdiepu.www.model.dz.dto.DzMortgageSub;
import com.zjdiepu.www.model.dz.dto.DzRegistration;
import com.zjdiepu.www.model.dz.ext.DzGpsExt;
import com.zjdiepu.www.model.dz.ext.DzLoanExitExt;
import com.zjdiepu.www.model.dz.ext.DzLoanMiddleAuditExt;
import com.zjdiepu.www.model.dz.ext.DzLoanMiddleBankExt;
import com.zjdiepu.www.model.dz.ext.DzMortgageExt;
import com.zjdiepu.www.model.dz.ext.DzMortgageSubExt;
import com.zjdiepu.www.model.dz.ext.DzRegistrationExt;
import com.zjdiepu.www.model.system.request.CustomerRestRequest;
import com.zjdiepu.www.model.system.response.CdDetailResponse;
import com.zjdiepu.www.model.system.response.ClDetailResponse;
import com.zjdiepu.www.model.system.response.ClcdxxDetailResponse;
import com.zjdiepu.www.model.system.response.ClxxDetailResponse;
import com.zjdiepu.www.model.system.response.ClxxbqDetailResponse;
import com.zjdiepu.www.model.system.response.CpxxDetailResponse;
import com.zjdiepu.www.model.system.response.DyxxDetailResponse;
import com.zjdiepu.www.model.system.response.FkxgDetailResponse;
import com.zjdiepu.www.model.system.response.GcrxxDetailResponse;
import com.zjdiepu.www.model.system.response.GjxxDetailResponse;
import com.zjdiepu.www.model.system.response.GpsxxDetailResponse;
import com.zjdiepu.www.model.system.response.GtgcrxxDetailResponse;
import com.zjdiepu.www.model.system.response.YhzdxgDetailResponse;
import com.zjdiepu.www.model.system.response.YwlcDetailResponse;
import com.zjdiepu.www.model.system.response.ZxqkDetailResponse;
import com.zjdiepu.www.model.yw.dto.YwBusiness;
import com.zjdiepu.www.model.yw.dto.YwBusinessBuyer;
import com.zjdiepu.www.model.yw.dto.YwBusinessCar;
import com.zjdiepu.www.model.yw.dto.YwBusinessCarAreaPrice;
import com.zjdiepu.www.model.yw.dto.YwBusinessLoan;
import com.zjdiepu.www.model.yw.ext.YwBusinessBuyerExt;
import com.zjdiepu.www.model.yw.ext.YwBusinessCarAreaPriceExt;
import com.zjdiepu.www.model.yw.ext.YwBusinessCarExt;
import com.zjdiepu.www.model.yw.ext.YwBusinessLoanExt;
import com.zjdiepu.www.model.zx.dto.ZxCreditQuery;
import com.zjdiepu.www.model.zx.dto.ZxQueryCreditApplySub;
import com.zjdiepu.www.model.zx.ext.ZxCreditQueryExt;
import com.zjdiepu.www.util.CachedEnums;
import com.zjdiepu.www.util.HtmlUtil;

/**
 * 客户资料Controller层<br/>
 * @author xiongxiaotun<br/>
 * @time 2017年04月24日 14时34分<br/>
 * @since 1.0<br/>
 */
@RestController
@RequestMapping(value= "CustomerRestController", produces="application/json;charset=UTF-8", method = RequestMethod.POST)
@Api(tags = {"客户资料"}, produces="application/json;charset=UTF-8")
public class CustomerRestController extends BaseController {
    @Resource
    private IYwBusinessService ywBusinessService;
    @Resource
    private IZxCreditQueryService zxCreditQueryService;
    @Resource
    private IZxQueryCreditApplySubService zxQueryCreditApplySubService;
    @Resource
    private IDzLoanMiddleBankService dzLoanMiddleBankService;
    @Resource
    private IDzLoanMiddleAuditService dzLoanMiddleAuditService;
    @Resource
    private IDzLoanExitService dzLoanExitService;
    @Resource
    private IYwBusinessBuyerService ywBusinessBuyerService;
    @Resource
    private IYwBusinessCarService ywBusinessCarService;
    @Resource
    private IYwBusinessLoanService ywBusinessLoanService;
    @Resource
    private IYwBusinessCarAreaPriceService ywBusinessCarAreaPriceService;
    @Resource
    private IDzRegistrationService dzRegistrationService;
    @Resource
    private IDzGpsService dzGpsService;
    @Resource
    private IDzMortgageService dzMortgageService;
    @Resource
    private IDzMortgageSubService dzMortgageSubService;
    @Resource
    private RedisObjectClient redisObjectClient;
    @Resource
    private IJuheProvinceService juheProvinceService;
    @Resource
    private IJuheCityService juheCityService;
    /**
     * @author xiongxiaotun <br/>
     * @Title: zxqkDetail  <br/>
     * @Description: 征信情况 <br/>
     * @param customerRestRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "征信情况", response = ZxqkDetailResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("zxqkDetail")
    public ApiResponse zxqkDetail(@Validated @RequestBody CustomerRestRequest customerRestRequest) {
    	YwBusiness ywBusiness = ywBusinessService.selectById(customerRestRequest.getBusiId());
    	if(null == ywBusiness) {
    		return ApiResponse.fail("999","该业务不存在或已经被删除");
    	}
    	String queryCreditApplyId = ywBusiness.getQueryCreditApplyId();
    	if(StringUtils.isBlank(queryCreditApplyId)) {
    		return ApiResponse.fail("999","征信查询结果不存在");
    	}
    	
    	ZxCreditQueryExt zxCreditQueryExt = new ZxCreditQueryExt();
    	zxCreditQueryExt.setBaseWhere();
    	zxCreditQueryExt.withOutPage();
    	zxCreditQueryExt.setQueryCreditApplyId(queryCreditApplyId);
    	zxCreditQueryExt.setOrderSql("(CASE WHEN `CREDIT_PEOPLE_TYPE` = '03' THEN 0 WHEN `CREDIT_PEOPLE_TYPE` = '01' THEN 1 WHEN `CREDIT_PEOPLE_TYPE` = '02' THEN 2 ELSE 3 END)");
    	List<ZxCreditQuery> zxCreditQuerys = zxCreditQueryService.selectByExt(zxCreditQueryExt);
    	if(CollectionUtils.isEmpty(zxCreditQuerys)) {
    		return ApiResponse.fail("999","征信查询结果不存在");
    	}
    	List<ZxqkDetailResponse> zxqkDetailResponses = CollectionInitUtil.emptyList();
    	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    	redisObjectClient.execute(new RedisCallback<Boolean>() {
			/**
			 * @param redisConnection
			 * @return
			 * @throws DataAccessException
			 */
			@Override
			public Boolean doInRedis(RedisConnection redisConnection)
					throws DataAccessException {
				for(ZxCreditQuery zxCreditQuery : zxCreditQuerys) {
					ZxqkDetailResponse zxqkDetailResponse = new ZxqkDetailResponse();
					
					String applySubId = zxCreditQuery.getQueryCreditApplySubId();
					if(StringUtils.isNotBlank(applySubId)) {
						ZxQueryCreditApplySub zxQueryCreditApplySub = zxQueryCreditApplySubService.selectById(applySubId);
						if(null != zxQueryCreditApplySub) {
							zxqkDetailResponse.setCusName(zxQueryCreditApplySub.getCusName());
							zxqkDetailResponse.setCusNo(zxQueryCreditApplySub.getCusNo());
						}
					}
					
					String creditPeopleType = zxCreditQuery.getCreditPeopleType();
					zxqkDetailResponse.setCreditPeopleType(zxCreditQuery.getCreditPeopleType());
					zxqkDetailResponse.setCreditResultMark(HtmlUtil.filterHtml(zxCreditQuery.getCreditResultMark()));
					
					SimpleDataDictionary simpleDataDictionary1 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), creditPeopleType, DataDicType.CREDIT_PEOPLE_TYPE.getCode());
					zxqkDetailResponse.setNameCreditPeopleType(simpleDataDictionary1 == null ? "" : simpleDataDictionary1.getName());
					Date operatorDate = zxCreditQuery.getOperatorDate();
					zxqkDetailResponse.setOperatorDate(null == operatorDate ? "-" : sdf.format(operatorDate));
					String bankCode = zxCreditQuery.getBankCode();
					SimpleDataDictionary simpleDataDictionary2 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), bankCode, DataDicType.LOAN_BANK.getCode());
					zxqkDetailResponse.setNameBankCode(simpleDataDictionary2 == null ? "" : simpleDataDictionary2.getName());
					String onceCarStatus = zxCreditQuery.getOnceCarStatus();
					SimpleDataDictionary simpleDataDictionary3 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), onceCarStatus, DataDicType.ONCE_CAR_STATUS.getCode());
					zxqkDetailResponse.setNameOnceCarStatus(simpleDataDictionary3 == null ? "" : simpleDataDictionary3.getName());
					String creditResult = zxCreditQuery.getCreditResult();
					SimpleDataDictionary simpleDataDictionary4 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), creditResult, DataDicType.CREDIT_RESULT.getCode());
					zxqkDetailResponse.setNameCreditResult(simpleDataDictionary4 == null ? "" : simpleDataDictionary4.getName());
					zxqkDetailResponses.add(zxqkDetailResponse);
				}
				return true;
			}
		});
		return ApiResponse.success(zxqkDetailResponses);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: gcrxxDetail  <br/>
     * @Description: 购车人信息 <br/>
     * @param customerRestRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "购车人信息", response = GcrxxDetailResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("gcrxxDetail")
    public ApiResponse gcrxxDetail(@Validated @RequestBody CustomerRestRequest customerRestRequest) {
    	String busiId = customerRestRequest.getBusiId();
    	// 查询购车人信息
		YwBusinessBuyerExt ywBusinessBuyerExt = new YwBusinessBuyerExt();
		ywBusinessBuyerExt.setBaseWhere();
		ywBusinessBuyerExt.setBusiId(busiId);
		ywBusinessBuyerExt.setRows(1);
		ywBusinessBuyerExt.setCarManType(CreditPeopleType.ZHU_JIE_REN.getCode());
		List<YwBusinessBuyer> ywBusinessBuyers = ywBusinessBuyerService.selectByExt(ywBusinessBuyerExt);
		if(CollectionUtils.isEmpty(ywBusinessBuyers)) {
    		return ApiResponse.fail("999","购车人信息缺失");
    	}
		YwBusinessBuyer ywBusinessBuyer = ywBusinessBuyers.get(0);
		GcrxxDetailResponse gcrxxDetailResponse = new GcrxxDetailResponse();
    	BeanUtils.copyProperties(ywBusinessBuyer, gcrxxDetailResponse);
		redisObjectClient.execute(new RedisCallback<Boolean>() {
			@Override
			public Boolean doInRedis(RedisConnection redisConnection)
					throws DataAccessException {
				String sex = ywBusinessBuyer.getSex();
				SimpleDataDictionary simpleDataDictionary1 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), sex, DataDicType.SEX.getCode());
				gcrxxDetailResponse.setNameSex(simpleDataDictionary1 == null ? "" : simpleDataDictionary1.getName());
				
				String maritalStatus = ywBusinessBuyer.getMaritalStatus();
				SimpleDataDictionary simpleDataDictionary2 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), maritalStatus, DataDicType.MARITAL_STATUS.getCode());
				gcrxxDetailResponse.setNameMaritalStatus(simpleDataDictionary2 == null ? "" : simpleDataDictionary2.getName());
				
				String education = ywBusinessBuyer.getEducation();
				SimpleDataDictionary simpleDataDictionary3 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), education, DataDicType.EDUCATION.getCode());
				gcrxxDetailResponse.setNameEducation(simpleDataDictionary3 == null ? "" : simpleDataDictionary3.getName());
				
				String job = ywBusinessBuyer.getJob();
				SimpleDataDictionary simpleDataDictionary4 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), job, DataDicType.JOB.getCode());
				gcrxxDetailResponse.setNameJob(simpleDataDictionary4 == null ? "" : simpleDataDictionary4.getName());
				
				String workAge = ywBusinessBuyer.getWorkAge();
				SimpleDataDictionary simpleDataDictionary5 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), workAge, DataDicType.WORK_AGE.getCode());
				gcrxxDetailResponse.setNameWorkAge(simpleDataDictionary5 == null ? "" : simpleDataDictionary5.getName());
				
				String contact1Relation = ywBusinessBuyer.getContact1Relation();
				SimpleDataDictionary simpleDataDictionary6 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), contact1Relation, DataDicType.CONTACT_RELATION.getCode());
				gcrxxDetailResponse.setContact1Relation(simpleDataDictionary6 == null ? "" : simpleDataDictionary6.getName());
				
				String contact2Relation = ywBusinessBuyer.getContact2Relation();
				SimpleDataDictionary simpleDataDictionary7 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), contact2Relation, DataDicType.CONTACT_RELATION.getCode());
				gcrxxDetailResponse.setContact2Relation(simpleDataDictionary7 == null ? "" : simpleDataDictionary7.getName());
				
				return true;
			}
		});
		return ApiResponse.success(gcrxxDetailResponse);
    }
    
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: gtgcrxxDetail  <br/>
     * @Description: 共同购车人信息 <br/>
     * @param customerRestRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "共同购车人信息", response = GtgcrxxDetailResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("gtgcrxxDetail")
    public ApiResponse gtgcrxxDetail(@Validated @RequestBody CustomerRestRequest customerRestRequest) {
    	String busiId = customerRestRequest.getBusiId();
    	// 查询购车人信息
		YwBusinessBuyerExt ywBusinessBuyerExt = new YwBusinessBuyerExt();
		ywBusinessBuyerExt.setBaseWhere();
		ywBusinessBuyerExt.setBusiId(busiId);
		ywBusinessBuyerExt.setRows(1);
		ywBusinessBuyerExt.setCarManType(CreditPeopleType.PEI_OU.getCode());
		List<YwBusinessBuyer> ywBusinessBuyers = ywBusinessBuyerService.selectByExt(ywBusinessBuyerExt);
		if(CollectionUtils.isEmpty(ywBusinessBuyers)) {
    		return ApiResponse.fail("999","共同购车人信息缺失");
    	}
		YwBusinessBuyer ywBusinessBuyer = ywBusinessBuyers.get(0);
		GtgcrxxDetailResponse gcrxxDetailResponse = new GtgcrxxDetailResponse();
		BeanUtils.copyProperties(ywBusinessBuyer, gcrxxDetailResponse);
		gcrxxDetailResponse.setRemarks(HtmlUtil.filterHtml(gcrxxDetailResponse.getRemarks()));
		redisObjectClient.execute(new RedisCallback<Boolean>() {
			@Override
			public Boolean doInRedis(RedisConnection redisConnection)
					throws DataAccessException {
				
				String job = ywBusinessBuyer.getJob();
				SimpleDataDictionary simpleDataDictionary1 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), job, DataDicType.JOB.getCode());
				gcrxxDetailResponse.setNameJob(simpleDataDictionary1 == null ? "" : simpleDataDictionary1.getName());
				
				String workAge = ywBusinessBuyer.getWorkAge();
				SimpleDataDictionary simpleDataDictionary2 = redisObjectClient.hGet(redisConnection,SimpleDataDictionary.class.getSimpleName(), workAge, DataDicType.WORK_AGE.getCode());
				gcrxxDetailResponse.setNameWorkAge(simpleDataDictionary2 == null ? "" : simpleDataDictionary2.getName());
				
				return true;
			}
		});
		return ApiResponse.success(gcrxxDetailResponse);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: clcdxxDetail  <br/>
     * @Description: 车辆&车贷信息 <br/>
     * @param customerRestRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "车辆&车贷信息", response = ClcdxxDetailResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("clcdxxDetail")
    public ApiResponse clcdxxDetail(@Validated @RequestBody CustomerRestRequest customerRestRequest) {
    	String busiId = customerRestRequest.getBusiId();
    	ClcdxxDetailResponse clcdxxDetailResponse = new ClcdxxDetailResponse();
    	// 查询车辆
    	YwBusinessCarExt ywBusinessCarExt = new YwBusinessCarExt();
		ywBusinessCarExt.setBaseWhere();
		ywBusinessCarExt.setRows(1);// 只能返回一条数据
		ywBusinessCarExt.setBusiId(busiId);
    	List<YwBusinessCar> ywBusinessCars = ywBusinessCarService.selectByExt(ywBusinessCarExt);
    	if(CollectionUtils.isEmpty(ywBusinessCars)) {
    		return ApiResponse.fail("999","车辆信息缺失");
    	}
    	YwBusinessCar ywBusinessCar = ywBusinessCars.get(0);
    	String carId = ywBusinessCar.getId();
    	if(StringUtils.isBlank(carId)) {
    		return ApiResponse.fail("999","车辆信息唯一标识缺失");
    	}
    	
    	ClDetailResponse clDetailResponse = new ClDetailResponse();
    	BeanUtils.copyProperties(ywBusinessCar, clDetailResponse);
    	//估价省/市
    	String evaluateProvince = ywBusinessCar.getEvaluateProvince();
    	clDetailResponse.setEvaluateProvince(juheProvinceService.getNameById(evaluateProvince));
    	String evaluateCity = ywBusinessCar.getEvaluateCity();
    	clDetailResponse.setEvaluateCity(juheCityService.getNameById(evaluateCity));
    	
    	//上牌地
		DzRegistrationExt dzRegistrationExt = new DzRegistrationExt();
		dzRegistrationExt.setBaseWhere();
		dzRegistrationExt.setRows(1);
		dzRegistrationExt.setCarId(ywBusinessCar.getId());
		dzRegistrationExt.setBusiId(busiId);
		List<DzRegistration> dzRegistrations = dzRegistrationService.selectByExt(dzRegistrationExt);
		if(CollectionUtils.isNotEmpty(dzRegistrations)) {
			DzRegistration dzRegistration = dzRegistrations.get(0);
			if(null != dzRegistration && StringUtils.isNotBlank(dzRegistration.getRegionRegistration())) {
				clDetailResponse.setRegistrationArea(dzRegistration.getRegionRegistration());
			}
		}
		
		// 查询购车人信息
		YwBusinessBuyerExt ywBusinessBuyerExt = new YwBusinessBuyerExt();
		ywBusinessBuyerExt.setBaseWhere();
		ywBusinessBuyerExt.setBusiId(busiId);
		ywBusinessBuyerExt.setRows(1);
		ywBusinessBuyerExt.setCarManType(CreditPeopleType.ZHU_JIE_REN.getCode());
		List<YwBusinessBuyer> ywBusinessBuyers = ywBusinessBuyerService.selectByExt(ywBusinessBuyerExt);
    	
		// 车贷信息 
		YwBusinessLoanExt ywBusinessLoanExt = new YwBusinessLoanExt();
		ywBusinessLoanExt.setBaseWhere();
		ywBusinessLoanExt.setRows(1);// 只能返回一条数据
		ywBusinessLoanExt.setBusiId(busiId);
		ywBusinessLoanExt.setCarId(carId);
		List<YwBusinessLoan> ywBusinessLoans = ywBusinessLoanService.selectByExt(ywBusinessLoanExt);
		
    	redisObjectClient.execute(new RedisCallback<Boolean>() {
			@Override
			public Boolean doInRedis(RedisConnection redisConnection)
					throws DataAccessException {
				String carStatus = ywBusinessCar.getCarStatus();
				SimpleDataDictionary simpleDataDictionary1 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), carStatus, DataDicType.CAR_STATUS.getCode());
				clDetailResponse.setNameCarStatus(simpleDataDictionary1 == null ? "" : simpleDataDictionary1.getName());
				
				String carPurpose = ywBusinessCar.getCarPurpose();
				SimpleDataDictionary simpleDataDictionary2 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), carPurpose, DataDicType.CAR_PURPOSE.getCode());
				clDetailResponse.setNameCarPurpose(simpleDataDictionary2 == null ? "" : simpleDataDictionary2.getName());
				
				String carType = ywBusinessCar.getCarType();
				SimpleDataDictionary simpleDataDictionary3 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), carType, DataDicType.CAR_TYPE.getCode());
				clDetailResponse.setNameCarType(simpleDataDictionary3 == null ? "" : simpleDataDictionary3.getName());
				
				String carPlace = ywBusinessCar.getCarPlace();
				SimpleDataDictionary simpleDataDictionary4 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), carPlace, DataDicType.CAR_PLACE.getCode());
				clDetailResponse.setNameCarPlace(simpleDataDictionary4 == null ? "" : simpleDataDictionary4.getName());
				
				String licencePlateType = ywBusinessCar.getLicencePlateType();
				SimpleDataDictionary simpleDataDictionary5 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), licencePlateType, DataDicType.LICENCE_PLATE_TYPE.getCode());
				clDetailResponse.setNameLicencePlateType(simpleDataDictionary5 == null ? "" : simpleDataDictionary5.getName());
				
				/*if(CollectionUtils.isNotEmpty(dzRegistrations)){
					DzRegistration dzRegistration = dzRegistrations.get(0);
					if(null != dzRegistration) {
						String provinceRegistration = dzRegistration.getProvinceRegistration();
						String areaRegistration = dzRegistration.getAreaRegistration();
						
						String provinceName = juheProvinceService.getNameById(provinceRegistration);
						String cityName = juheCityService.getNameById(areaRegistration);
						String regionName = null;
						if(StringUtils.isNotBlank(provinceName)) {
							regionName = provinceName.equals(cityName) ? provinceName : provinceName + "-" + cityName;
							clDetailResponse.setRegionRegistration(regionName);//上牌地
						}
					}
				}*/
				
				if(CollectionUtils.isNotEmpty(ywBusinessBuyers)) {
					YwBusinessBuyer ywBusinessBuyer = ywBusinessBuyers.get(0);
					if(null != ywBusinessBuyer) {
						clDetailResponse.setRegionRegistration(ywBusinessBuyer.getArea());
					}
		    	}
				
				if (CollectionUtils.isNotEmpty(ywBusinessLoans)) {
					YwBusinessLoan ywBusinessLoan = ywBusinessLoans.get(0);
					CdDetailResponse cdDetailResponse = new CdDetailResponse();
		    		BeanUtils.copyProperties(ywBusinessLoan, cdDetailResponse);
		    		cdDetailResponse.setRemarks(HtmlUtil.filterHtml(cdDetailResponse.getRemarks()));
					
					Integer startYear = ywBusinessCar.getStartYear();
					Integer startMonth = ywBusinessCar.getStartMonth();
					if(null != startYear && null != startMonth) {
						cdDetailResponse.setFirstDate(startYear + new DecimalFormat("00").format(startMonth));
					}
					
					String loanBank = ywBusinessLoan.getLoanBank();
					SimpleDataDictionary simpleDataDictionary6 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), loanBank, DataDicType.LOAN_BANK.getCode());
					cdDetailResponse.setNameLoanBank(simpleDataDictionary6 == null ? "" : simpleDataDictionary6.getName());
					
					String loanType = ywBusinessLoan.getLoanType();
					SimpleDataDictionary simpleDataDictionary7 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), loanType, DataDicType.LOAN_TYPE.getCode());
					cdDetailResponse.setNameLoanType(simpleDataDictionary7 == null ? "" : simpleDataDictionary7.getName());
					
					Integer loanMonth = ywBusinessLoan.getLoanMonth();
					SimpleDataDictionary simpleDataDictionary8 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), String.valueOf(loanMonth), DataDicType.LOAN_MONTH.getCode());
					cdDetailResponse.setNameLoanMonth(simpleDataDictionary8 == null ? "" : simpleDataDictionary8.getName());
					
					clcdxxDetailResponse.setCdDetailResponse(cdDetailResponse);
				}
				
				return true;
			}
		});
    	
    	//车辆估价
    	YwBusinessCarAreaPriceExt ywBusinessCarAreaPriceExt = new YwBusinessCarAreaPriceExt();
    	ywBusinessCarAreaPriceExt.setBaseWhere();
    	ywBusinessCarAreaPriceExt.withOutPage();
    	ywBusinessCarAreaPriceExt.setBusiId(busiId);
    	ywBusinessCarAreaPriceExt.setCarId(carId);
    	ywBusinessCarAreaPriceExt.setOrderSql("`AREA_ID` ASC");
    	List<YwBusinessCarAreaPrice> ywBusinessCarAreaPrices = ywBusinessCarAreaPriceService.selectByExt(ywBusinessCarAreaPriceExt);
    	List<GjxxDetailResponse> gjxxDetailResponses = CollectionInitUtil.emptyList();
    	if(CollectionUtils.isNotEmpty(ywBusinessCarAreaPrices)) {
    		for(YwBusinessCarAreaPrice ywBusinessCarAreaPrice : ywBusinessCarAreaPrices) {
    			GjxxDetailResponse gjxxDetailResponse = new GjxxDetailResponse();
    			gjxxDetailResponse.setAreaName(ywBusinessCarAreaPrice.getAreaName());
    			gjxxDetailResponse.setPrice(ywBusinessCarAreaPrice.getPrice());
    			gjxxDetailResponses.add(gjxxDetailResponse);
    		}
    	}
    	clDetailResponse.setGjxxDetailResponses(gjxxDetailResponses);
    	clcdxxDetailResponse.setClDetailResponse(clDetailResponse);
    	
		
		return ApiResponse.success(clcdxxDetailResponse);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: ywlcDetail  <br/>
     * @Description: 业务流程 <br/>
     * @param customerRestRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "业务流程", response = YwlcDetailResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("ywlcDetail")
    public ApiResponse ywlcDetail(@Validated @RequestBody CustomerRestRequest customerRestRequest) {
    	String busiId = customerRestRequest.getBusiId();
    	
    	YwlcDetailResponse ywlcDetailResponse = new YwlcDetailResponse();
    	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    	/*贷中信息登记：风控*/
    	DzLoanMiddleAuditExt dzLoanMiddleAuditExt = new DzLoanMiddleAuditExt();
    	dzLoanMiddleAuditExt.setBaseWhere();
    	dzLoanMiddleAuditExt.setRows(1);
    	dzLoanMiddleAuditExt.setBusiId(busiId);
    	List<DzLoanMiddleAudit> dzLoanMiddleAudits = dzLoanMiddleAuditService.selectByExt(dzLoanMiddleAuditExt);
    	if(CollectionUtils.isNotEmpty(dzLoanMiddleAudits)) {
    		DzLoanMiddleAudit dzLoanMiddleAudit = dzLoanMiddleAudits.get(0);
    		FkxgDetailResponse fkxgDetailResponse = new FkxgDetailResponse();
	    	BeanUtils.copyProperties(dzLoanMiddleAudit, fkxgDetailResponse);
    		fkxgDetailResponse.setTimeApplyOpencard(null == dzLoanMiddleAudit.getTimeApplyOpencard() ? "-" : sdf.format(dzLoanMiddleAudit.getTimeApplyOpencard()));
    		fkxgDetailResponse.setTimeReceiveContract(null == dzLoanMiddleAudit.getTimeReceiveContract() ? "-" : sdf.format(dzLoanMiddleAudit.getTimeReceiveContract()));
    		fkxgDetailResponse.setTimeContractFull(null == dzLoanMiddleAudit.getTimeContractFull() ? "-" : sdf.format(dzLoanMiddleAudit.getTimeContractFull()));
    		fkxgDetailResponse.setTimeContractPrint(null == dzLoanMiddleAudit.getTimeContractPrint() ? "-" : sdf.format(dzLoanMiddleAudit.getTimeContractPrint()));
    		fkxgDetailResponse.setTimeContractHandPrint(null == dzLoanMiddleAudit.getTimeContractHandPrint() ? "-" : sdf.format(dzLoanMiddleAudit.getTimeContractHandPrint()));
    		fkxgDetailResponse.setTimeSendToBank(null == dzLoanMiddleAudit.getTimeSendToBank() ? "-" : sdf.format(dzLoanMiddleAudit.getTimeSendToBank()));
    		
    		/*退贷*/
        	DzLoanExitExt dzLoanExitExt = new DzLoanExitExt();
        	dzLoanExitExt.setBaseWhere();
        	dzLoanExitExt.setRows(1);
        	dzLoanExitExt.setBusiId(busiId);
        	List<DzLoanExit> dzLoanExits = dzLoanExitService.selectByExt(dzLoanExitExt);
        	if(CollectionUtils.isNotEmpty(dzLoanExits)) {
        		DzLoanExit dzLoanExit = dzLoanExits.get(0);
        		fkxgDetailResponse.setDateExit(null == dzLoanExit.getDateExit() ? "-" : sdf.format(dzLoanExit.getDateExit()));
        	}
    		ywlcDetailResponse.setFkxgDetailResponse(fkxgDetailResponse);
    	}
    	
    	/*贷中信息登记：银行*/
    	DzLoanMiddleBankExt dzLoanMiddleBankExt = new DzLoanMiddleBankExt();
    	dzLoanMiddleBankExt.setBaseWhere();
    	dzLoanMiddleBankExt.setRows(1);
    	dzLoanMiddleBankExt.setBusiId(busiId);
    	List<DzLoanMiddleBank> dzLoanMiddleBanks = dzLoanMiddleBankService.selectByExt(dzLoanMiddleBankExt);
    	if(CollectionUtils.isNotEmpty(dzLoanMiddleBanks)) {
    		DzLoanMiddleBank dzLoanMiddleBank = dzLoanMiddleBanks.get(0);
    		YhzdxgDetailResponse yhzdxgDetailResponse = new YhzdxgDetailResponse();
	    	BeanUtils.copyProperties(dzLoanMiddleBank, yhzdxgDetailResponse);
    		yhzdxgDetailResponse.setTimeReceiveBank(null == dzLoanMiddleBank.getTimeReceiveBank() ? "-" : sdf.format(dzLoanMiddleBank.getTimeReceiveBank()));
    		yhzdxgDetailResponse.setTimeReceiveOpencard(null == dzLoanMiddleBank.getTimeReceiveOpencard() ? "-" : sdf.format(dzLoanMiddleBank.getTimeReceiveOpencard()));
    		yhzdxgDetailResponse.setTimeSubsequentInform(null == dzLoanMiddleBank.getTimeSubsequentInform() ? "-" : sdf.format(dzLoanMiddleBank.getTimeSubsequentInform()));
    		yhzdxgDetailResponse.setTimeSubsequentReceive(null == dzLoanMiddleBank.getTimeSubsequentReceive() ? "-" : sdf.format(dzLoanMiddleBank.getTimeSubsequentReceive()));
    		yhzdxgDetailResponse.setDateBank(null == dzLoanMiddleBank.getDateBank() ? "-" : sdf.format(dzLoanMiddleBank.getDateBank()));
    		
    		ywlcDetailResponse.setYhzdxgDetailResponse(yhzdxgDetailResponse);
    	}
        return ApiResponse.success(ywlcDetailResponse);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: clxxbqDetail  <br/>
     * @Description: 车辆信息补全 <br/>
     * @param customerRestRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "车辆信息补全", response = ClxxbqDetailResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("clxxbqDetail")
    public ApiResponse clxxbqDetail(@Validated @RequestBody CustomerRestRequest customerRestRequest) {
    	String busiId = customerRestRequest.getBusiId();
    	// 查询车辆&车贷信息
    	YwBusinessCarExt ywBusinessCarExt = new YwBusinessCarExt();
		ywBusinessCarExt.setBaseWhere();
		ywBusinessCarExt.setRows(1);// 只能返回一条数据
		ywBusinessCarExt.setBusiId(busiId);
    	List<YwBusinessCar> ywBusinessCars = ywBusinessCarService.selectByExt(ywBusinessCarExt);
    	if(CollectionUtils.isEmpty(ywBusinessCars)) {
    		return ApiResponse.fail("999","车辆信息缺失");
    	}
    	YwBusinessCar ywBusinessCar = ywBusinessCars.get(0);
    	
    	//车牌号
		DzRegistrationExt dzRegistrationExt = new DzRegistrationExt();
		dzRegistrationExt.setBaseWhere();
		dzRegistrationExt.setRows(1);
		dzRegistrationExt.setCarId(ywBusinessCar.getId());
		dzRegistrationExt.setBusiId(busiId);
		List<DzRegistration> dzRegistrations = dzRegistrationService.selectByExt(dzRegistrationExt);
		
		ClxxbqDetailResponse clxxbqDetailResponse = new ClxxbqDetailResponse();
    	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    	redisObjectClient.execute(new RedisCallback<Boolean>() {
			/**
			 * @param redisConnection
			 * @return
			 * @throws DataAccessException
			 */
			@Override
			public Boolean doInRedis(RedisConnection redisConnection)
					throws DataAccessException {
		    	ClxxDetailResponse clxxDetailResponse = new ClxxDetailResponse();
		    	BeanUtils.copyProperties(ywBusinessCar, clxxDetailResponse);
		    	String carType = ywBusinessCar.getCarType();
		    	SimpleDataDictionary simpleDataDictionary1 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), carType, DataDicType.CAR_TYPE.getCode());
		    	clxxDetailResponse.setNameCarType(simpleDataDictionary1 == null ? "" : simpleDataDictionary1.getName());
		    	
		    	String colorCar = ywBusinessCar.getColorCar();
		    	SimpleDataDictionary simpleDataDictionary2 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), colorCar, DataDicType.CAR_COLOR.getCode());
		    	clxxDetailResponse.setNameColorCar(simpleDataDictionary2 == null ? "" : simpleDataDictionary2.getName());
		    	
		    	Date dateBill = ywBusinessCar.getDateBill();
		    	clxxDetailResponse.setDateBill(dateBill == null ? "-" : sdf.format(dateBill));
    	
		    	clxxbqDetailResponse.setClxxDetailResponse(clxxDetailResponse);
		    	
		    	DzRegistration dzRegistration = null;
		    	if(CollectionUtils.isNotEmpty(dzRegistrations)){
					dzRegistration = dzRegistrations.get(0);
				}
		    	if(null != dzRegistration) {
		    		CpxxDetailResponse cpxxDetailResponse = new CpxxDetailResponse();
			    	BeanUtils.copyProperties(dzRegistration, cpxxDetailResponse);
		    		cpxxDetailResponse.setRemarks(HtmlUtil.filterHtml(cpxxDetailResponse.getRemarks()));
    				String provinceRegistration = dzRegistration.getProvinceRegistration();
    				String areaRegistration = dzRegistration.getAreaRegistration();
    				
    				String provinceName = juheProvinceService.getNameById(provinceRegistration);
    				String cityName = juheCityService.getNameById(areaRegistration);
    				String regionName = null;
    				if(StringUtils.isNotBlank(provinceName)) {
    					regionName = provinceName.equals(cityName) ? provinceName : provinceName + "-" + cityName;
    					cpxxDetailResponse.setRegionRegistration(regionName);//上牌地
    				}
		    		
		    		Date dateRegistrationFirst = dzRegistration.getDateRegistrationFirst();
		    		Date dateRegistrationNow = dzRegistration.getDateRegistrationNow();
		    		
		    		cpxxDetailResponse.setDateRegistrationFirst(null == dateRegistrationFirst ? "-" : sdf.format(dateRegistrationFirst));
		    		cpxxDetailResponse.setDateRegistrationNow(null == dateRegistrationNow ? "-" : sdf.format(dateRegistrationNow));
		    		
		    		clxxbqDetailResponse.setCpxxDetailResponse(cpxxDetailResponse);
		    		
		    	}
		    	return true;
			}
		});
		return ApiResponse.success(clxxbqDetailResponse);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: gpsxxDetail  <br/>
     * @Description: GPS信息 <br/>
     * @param customerRestRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "GPS信息", response = GpsxxDetailResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("gpsxxDetail")
    public ApiResponse gpsxxDetail(@Validated @RequestBody CustomerRestRequest customerRestRequest) {
    	String busiId = customerRestRequest.getBusiId();
    	// 查询GPS信息
    	DzGpsExt dzGpsExt = new DzGpsExt();
    	dzGpsExt.setBaseWhere();
    	dzGpsExt.withOutPage();
    	dzGpsExt.setBusiId(busiId);
    	List<DzGps> dzGpses = dzGpsService.selectByExt(dzGpsExt);
    	
    	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    	List<GpsxxDetailResponse> gpsxxDetailResponses = CollectionInitUtil.emptyList();
    	redisObjectClient.execute(new RedisCallback<Boolean>() {
			@Override
			public Boolean doInRedis(RedisConnection redisConnection)
					throws DataAccessException {
				for(DzGps dzGps : dzGpses) {
					GpsxxDetailResponse gpsxxDetailResponse = new GpsxxDetailResponse();
		    		BeanUtils.copyProperties(dzGps, gpsxxDetailResponse);
		    		
		    		Date timeInstall = dzGps.getTimeInstall();
		    		gpsxxDetailResponse.setTimeInstall(null == timeInstall ? "-" : sdf.format(timeInstall));
					
					gpsxxDetailResponses.add(gpsxxDetailResponse);
				}
				return true;
			}
		});
		return ApiResponse.success(gpsxxDetailResponses);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: dyxxDetail  <br/>
     * @Description: 抵押信息 <br/>
     * @param customerRestRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "抵押信息", response = DyxxDetailResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("dyxxDetail")
    public ApiResponse dyxxDetail(@Validated @RequestBody CustomerRestRequest customerRestRequest) {
    	String busiId = customerRestRequest.getBusiId();
    	// 查询抵押详情
    	DzMortgageExt dzMortgageExt = new DzMortgageExt();
    	dzMortgageExt.setBaseWhere();
    	dzMortgageExt.setRows(1);
    	dzMortgageExt.setBusiId(busiId);
    	List<DzMortgage> dzMortgages = dzMortgageService.selectByExt(dzMortgageExt);
    	if(CollectionUtils.isEmpty(dzMortgages)) {
    		return ApiResponse.fail("999","抵押信息缺失");
    	}
    	DzMortgage dzMortgage = dzMortgages.get(0);
    	
    	DzMortgageSubExt dzMortgageSubExt = new DzMortgageSubExt();
		dzMortgageSubExt.setBaseWhere();
		dzMortgageSubExt.setRows(1);
		dzMortgageSubExt.setBusiId(busiId);
		List<DzMortgageSub> dzMortgageSubs = dzMortgageSubService.selectByExt(dzMortgageSubExt);
		if(CollectionUtils.isEmpty(dzMortgageSubs)) {
    		return ApiResponse.fail("999","抵押信息缺失");
    	}
		DzMortgageSub dzMortgageSub = dzMortgageSubs.get(0);
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		DyxxDetailResponse dyxxDetailResponse = new DyxxDetailResponse();
		
		dyxxDetailResponse.setRemarks(HtmlUtil.filterHtml(dyxxDetailResponse.getRemarks()));
		dyxxDetailResponse.setDateDjzsyj(null == dzMortgageSub.getDateDjzsyj() ? "-" : sdf.format(dzMortgageSub.getDateDjzsyj()));
		dyxxDetailResponse.setDateFpyj(null == dzMortgageSub.getDateFpyj() ? "-" : sdf.format(dzMortgageSub.getDateFpyj()));
		dyxxDetailResponse.setDateZzzyj(null == dzMortgageSub.getDateZzzyj() ? "-" : sdf.format(dzMortgageSub.getDateZzzyj()));
		dyxxDetailResponse.setDateSybxyj(null == dzMortgageSub.getDateSybxyj() ? "-" : sdf.format(dzMortgageSub.getDateSybxyj()));
		dyxxDetailResponse.setDateJqxbdyj(null == dzMortgageSub.getDateJqxbdyj() ? "-" : sdf.format(dzMortgageSub.getDateJqxbdyj()));
		dyxxDetailResponse.setDateXszfyj(null == dzMortgageSub.getDateXszfyj() ? "-" : sdf.format(dzMortgageSub.getDateXszfyj()));
		dyxxDetailResponse.setDateGzclsyhgz(null == dzMortgageSub.getDateGzclsyhgz() ? "-" : sdf.format(dzMortgageSub.getDateGzclsyhgz()));
		dyxxDetailResponse.setDateGzclyhgzfh(null == dzMortgageSub.getDateGzclyhgzfh() ? "-" : sdf.format(dzMortgageSub.getDateGzclyhgzfh()));
		dyxxDetailResponse.setDateGzclsgzc(null == dzMortgageSub.getDateGzclsgzc() ? "-" : sdf.format(dzMortgageSub.getDateGzclsgzc()));
		dyxxDetailResponse.setDateGzcgzhtfh(null == dzMortgageSub.getDateGzcgzhtfh() ? "-" : sdf.format(dzMortgageSub.getDateGzcgzhtfh()));
		dyxxDetailResponse.setDateSjgz(null == dzMortgageSub.getDateSjgz() ? "-" : sdf.format(dzMortgageSub.getDateSjgz()));
		dyxxDetailResponse.setDateGzjdyclfhgs(null == dzMortgageSub.getDateGzjdyclfhgs() ? "-" : sdf.format(dzMortgageSub.getDateGzjdyclfhgs()));
		dyxxDetailResponse.setDateDyclsyhgz(null == dzMortgageSub.getDateDyclsyhgz() ? "-" : sdf.format(dzMortgageSub.getDateDyclsyhgz()));
		dyxxDetailResponse.setDateDyclsdyry(null == dzMortgageSub.getDateDyclsdyry() ? "-" : sdf.format(dzMortgageSub.getDateDyclsdyry()));
		dyxxDetailResponse.setDateDyclyhgzfh(null == dzMortgageSub.getDateDyclyhgzfh() ? "-" : sdf.format(dzMortgageSub.getDateDyclyhgzfh()));
		dyxxDetailResponse.setDateDywcdjzsfh(null == dzMortgageSub.getDateDywcdjzsfh() ? "-" : sdf.format(dzMortgageSub.getDateDywcdjzsfh()));
		
		dyxxDetailResponse.setDateMortgage(null == dzMortgage.getDateMortgage() ? "-" : sdf.format(dzMortgage.getDateMortgage()));
		dyxxDetailResponse.setOperatorMortgage(dzMortgage.getOperatorMortgage());
		dyxxDetailResponse.setNameStatusMortgage(dzMortgage.getStatusMortgage() == null ? "-" : (String)CachedEnums.getValue("0" + dzMortgage.getStatusMortgage(), MortgageStatus.class));
		dyxxDetailResponse.setRemarks(HtmlUtil.filterHtml(dzMortgage.getRemarks()));
		return ApiResponse.success(dyxxDetailResponse);
    }
}
